<!-- eslint-disable vue/multi-word-component-names -->
<template>
    <div id="ventilate"></div>
  </template>
  
  <script lang="ts" setup>
  import { onMounted } from "vue";
  import * as echarts from "echarts";
  
  onMounted(() => {
    var chartDom = document.getElementById("ventilate");
    var myChart = echarts.init(chartDom);
  
    let option = {
      tooltip: {
        trigger: "axis",
      },
      grid: {
        top: "4%",
        left: "2%",
        right: "4%",
        bottom: '22%',
        containLabel: true,
      },
      xAxis: {
        type: "category",
        data: ["6:00", "8:00", "10:00", "12:00", "14:00", "16:00", "18:00", "20:00", "22:00", "24:00"],
        axisLabel: {
          color: "#CFCFCF",
          interval: 0,
          fontSize: 12,
        },
        axisTick: {
          show: false,
        },
      },
      yAxis: {
        type: "value",
        data:[0,200,400,600,800],
        axisLabel: {
          show: true,
          color: "#CFCFCF",
          fontSize: 12,
          formatter: '{value}m³',
        },
  
        splitLine: {
          show: true,
          lineStyle: {
            width: 0.8,
            color: "rgba(127, 214, 255, .4)",
            type: "dashed",
          },
        },
      },
      series: [
        {
          type: "line",
          showSymbol: false,
          smooth: true,
          // symbolSize: 8,
          lineStyle: {
            color: "rgb(21, 255, 0)",
          },
          itemStyle: {
            color: "rgb(21, 255, 0)",
            borderColor: "rgb(21, 255, 0)",
            borderWidth: 2,
          },
          areaStyle: {
            color: {
              type: "linear",
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              colorStops: [
                {
                  offset: 0.25,
                  color: "rgb(21, 255, 0)",
                },
                {
                  offset: 1,
                  color: "rgba(21, 255, 0, 0)",
                },
              ],
            },
          },
          data: [1000, 1234, 1500, 1600, 1750, 2110, 1878, 1980, 2112, 2327],
        },
      ],
    };
    option && myChart.setOption(option);
    //监听窗口变化
    window.addEventListener("resize", function () {
      console.log("监听窗口变化");
      myChart.resize();
    });
  });
  </script>
  
  <style scoped>
  #ventilate {
    width: 41vw;
    height: 40vh;
  }
  
  
  </style>